package org.cloudnote.util;



import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
//import java.util.Base64;
import java.util.UUID;

public class NoteUtil {
    
    public static String createdId(){
        UUID uuid = UUID.randomUUID();
        return uuid.toString();
    }

    public static String md5(String str){
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] input = str.getBytes();
            byte[] output = md.digest(input);
            //return Base64.encode(output);
            return Base64.encode(output);
        } catch (NoSuchAlgorithmException e) {
            return "";
        }
    }

    public static void main(String[] args) {
        //String s = createdId();
       // System.out.println("s = " + s);
        String s = md5("123");
        System.out.println("s = " + s); //ICy5YqxZB1uWSwcVLSNLcA==
                                       // ICy5YqxZB1uWSwcVLSNLcA==
    }
    
}
